import { AxiosInstance, AxiosRequestConfig } from './types'
import Axios from './core/Axios'
import { extend } from './helpers/util'
import defaults from '../src/helpers/default'

function createInstance(config: AxiosRequestConfig): AxiosInstance {
  const context = new Axios(config)
  const instant = Axios.prototype.request.bind(context)

  extend(instant, context)
  return instant as AxiosInstance
}

const axios = createInstance(defaults)

export default axios
